package com.code.monitor.resolve;

import com.code.monitor.model.MethodBean;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @author ggh
 * @date 2023/5/8
 */
public class UriMappingReslover {
    private static final ConcurrentHashMap<Class, MethodBean> exceptionMappings = new ConcurrentHashMap<>();
    private static final ConcurrentHashMap<String, MethodBean> uriMappings = new ConcurrentHashMap<>();

    public static void addUriMapping(String uri, MethodBean methodBean) {
        uriMappings.put(uri, methodBean);
    }

    public static MethodBean getUriMapping(String uri) {
        return uriMappings.get(uri);
    }

    public static void addExMappings(Class ex, MethodBean methodBean) {
        exceptionMappings.put(ex, methodBean);
    }

    public static MethodBean getExMappings(Class ex) {
        return exceptionMappings.get(ex);
    }

    public static void print() {
        uriMappings.forEach((key, value) -> {
            System.out.println(key + ":" + value);
        });
    }
}
